/*
 * @Descripttion:
 * @version:
 * @Author: WangMingJun
 * @Date: 2021-10-07 12:09:43
 * @LastEditors: WangMingJun
 * @LastEditTime: 2024-06-26 16:59:17
 */
import axios from 'axios'
import store from '../store/index'
axios.defaults.baseURL = process.env.VUE_APP_BASEURL

export default function setAxios() {
  //请求拦截
  axios.interceptors.request.use((config) => {
    if (store.state.token) {
      // 将token设置在headers ['Authorization'] 上面
      config.headers['Authorization'] = `Bearer ${store.state.token}`
    }
    return config
  })
}
